package com.copa.module.user.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.copa.domain.PageVo;
import com.copa.domain.ResponseDto;
import com.copa.module.user.domain.dto.AddressDto;
import com.copa.module.user.domain.entity.UserAddressEntity;
import com.copa.module.user.mapper.UserAddressDao;
import com.copa.module.user.service.UserAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author copa
 * @createDate 2021-01-09 14:05
 * @function
 */
@Service
public class UserAddressServiceImpl implements UserAddressService {

    @Autowired
    private UserAddressDao userAddressDao;

    @Override
    public ResponseDto<List<AddressDto>> list(Long userId) {
        List<AddressDto> userAddressEntities = userAddressDao.findAddressDtoByUserId(userId);
        if (ObjectUtil.isNotNull(userAddressEntities)
                && ObjectUtil.length(userAddressEntities) > 0) {
            return ResponseDto.success(userAddressEntities);
        }
        return ResponseDto.errorMsg("抱歉，查不到该用户的地址！");
    }
}
